var apireadyMap = [initPage];
var pagenext = 1;

function initPage() {
    dropload.config({
        scrollRange: 10,
        htmlNothing: function() {
            return '';
        },
        callback: orderDatabase.init
    });
    dropload.init(document.getElementById('dropView'));
    dropload.loading();
    orderDatabase.init();
}

var orderDatabase = {
    init: function() {
        var self = orderDatabase;
        var data_opt = {
            page: pagenext
        };
        ajax.get('/api?ctrl.order.volist', data_opt, function(res) {
            if(res.state) {
                pagenext = res.data.next;
                if(res.data.list.length > 0) {
                    document.querySelector('#ipt-total_money').innerHTML = res.data.total_money;
                    self.render(res.data.list);
                } else {
                    // nothing...
                }
                if(res.data.next > 0) {
                    dropload.resetLoad();
                } else {
                    dropload.noData();
                }
            } else {
                setTimeout(self.init, 1600);
            }
        });
    },
    render: function(data) {
        for(var i in data) {
            var list = data[i];
            var ele = '';
            ele += '<td align="center">' + list.mobile + '</td>';
            ele += '<td align="center">' + list.days + '</td>';
            ele += '<td align="center" class="c-money">' + list.money + '</td>';
            ele += '<td align="center">' + tool.formatDate('yy/mm/dd hh:ii:ss', list.update_time) + '</td>';
            var tr = document.createElement('tr');
            tr.innerHTML = ele;
            document.querySelector('#databaseVolist').appendChild(tr);
        }
    }
};